function Util() {

};
// ////////static methods////////////////
Util.isEmpty = function(str){
	if(typeof str == null || str == "" || str == undefined) {
        return true;
    } else {
        return false;
    }
}
/**
 * Figures rounded to a specified number of decimal places
 * 
 * @param {float}
 *            base number
 * @param {int}
 *            precision Decimal places
 */
Util.roundTo = function(base, precision) {
	var m = Math.pow(10, precision);
	var a = Math.round(base * m) / m;
	return a;
};
/**
 * Get the command word of message from server
 * 
 * @param {Object}
 *            message The message from server
 */
Util.getCmdId = function(message) {
	return message.substring(0, message.indexOf(cmdFlag.CMDFlagSeperator));
};

/**
 * dispatch task according to the message from server
 * 
 * @param {Object}
 *            message the message from server
 */
Util.dispatchTask = function(message) {
	var cmd = Util.getCmdId(message);
	switch (cmd) {
		case cmdFlag.CMD4Build :
			Util.processBuild(Util.getInfoJson(message));
			break;
		case cmdFlag.CMD4Pack :
			Util.processPack(Util.getInfoJson(message));
			break;
		case cmdFlag.CMD4Run :
			break;
		case cmdFlag.CMD4Test :
			break;
		case cmdFlag.CMD4Log :
			Util.processLog(Util.getLogJson(message));
			break;
		case cmdFlag.CMD4Device :
			Util.processDevice(Util.getInfoJson(message));
			break;
		case cmdFlag.CMD4IDCode :
			Util.processIdCode(Util.getInfoJson(message));
			break;
		case cmdFlag.CMD4User :
			Util.processUser(Util.getInfoJson(message));
			break;
		case cmdFlag.CMD4App :
			Util.processPlugin(Util.getInfoJson(message));
			break;
		case cmdFlag.CMD4Service :
			Util.processService(Util.getInfoJson(message));
			break;
		case cmdFlag.CMD4Cer :
			Util.processCer(Util.getInfoJson(message));
			break;
		case cmdFlag.CMD4Dir :
			Util.pluginpath=message.substring(5);
			break;
		default :
			break;
	}
};
Util.processPack = function(packInfoJson) {
	var processType = packInfoJson.substring(1, packInfoJson
					.indexOf(cmdFlag.CMDFlagSeperator));
	var jsonData = Ext.JSON.decode(packInfoJson.substring(packInfoJson
			.indexOf(cmdFlag.CMDFlagSeperator)
			+ 1));
	if (processType == 'F') {
		Util.loadingMaskPanel.show();
		Ext.getCmp('waitingPanel').setModal(false);
		Ext.getCmp('waitingPanel').setHtml('[' + jsonData.nameCN
				+ ']&nbsp;&nbsp;' + I18N.packF);
		setTimeout(function() {
					Util.loadingMaskPanel.hide();
					Ext.getCmp('waitingPanel').setHtml(I18N.waiting);
					Ext.getCmp('waitingPanel').setModal(true);
				}, 1500);
	} else if (processType == 'S') {
		Util.loadingMaskPanel.show();
		Ext.getCmp('waitingPanel').setModal(false);
		Ext.getCmp('waitingPanel').setHtml('[' + jsonData.nameCN
				+ ']&nbsp;&nbsp;' + I18N.packS);
		setTimeout(function() {
					Util.loadingMaskPanel.hide();
					Ext.getCmp('waitingPanel').setHtml(I18N.waiting);
					Ext.getCmp('waitingPanel').setModal(true);
				}, 1500);
	}else if(processType == 'B'){
		Util.loadingMaskPanel.hide();
		Ext.getCmp('waitingPanel').hide();
		Ext.Msg.show({
		     message: I18N.afterBuilder,
		     buttons: [
		    	 {text:'确定',itemId:'ok'},
		     ]
		});
	}
};
Util.processBuild = function(buildInfoJson) {
	var processType = buildInfoJson.substring(1, buildInfoJson
					.indexOf(cmdFlag.CMDFlagSeperator));
	var jsonData = Ext.JSON.decode(buildInfoJson.substring(buildInfoJson
			.indexOf(cmdFlag.CMDFlagSeperator)
			+ 1));
	if (processType == 'F') {
		Ext.getCmp('waitingPanel').setModal(false);
		Ext.getCmp('waitingPanel').setHtml('[' + jsonData.nameCN
				+ ']&nbsp;&nbsp;' + I18N.buildF);
		setTimeout(function() {
					Util.loadingMaskPanel.hide();
					Ext.getCmp('waitingPanel').setHtml(I18N.waiting);
					Ext.getCmp('waitingPanel').setModal(true);
				}, 1500);
	} else if (processType == 'S') {
		Util.loadingMaskPanel.show();
		Ext.getCmp('waitingPanel').setModal(false);
		Ext.getCmp('waitingPanel').setHtml('[' + jsonData.nameCN
				+ ']&nbsp;&nbsp;' + I18N.buildS);
		setTimeout(function() {
					Util.loadingMaskPanel.hide();
					Ext.getCmp('waitingPanel').setHtml(I18N.waiting);
					Ext.getCmp('waitingPanel').setModal(true);
				}, 1500);
	}
};
Util.processService = function(serviceInfoJson) {
	var processType = serviceInfoJson.substring(1, serviceInfoJson
					.indexOf(cmdFlag.CMDFlagSeperator));
	var jsonData = Ext.JSON.decode(serviceInfoJson.substring(serviceInfoJson
			.indexOf(cmdFlag.CMDFlagSeperator)
			+ 1));
	var store = Ext.data.StoreManager.lookup('serviceStore');
	if (processType == 'A') {
		store.add(jsonData);
		Ext.getCmp('ide_service_regist_panel').hide();
	} else if (processType == 'D') {
		store.each(function(item, index, length) {
					if (item.get("id") == jsonData.id) {
						store.remove(item);
						return false;
					}
				});
	} else if (processType == 'L') {
		store.add(jsonData);
	} else if (processType == 'E') {
		store.each(function(item, index, length) {
					if (item.get("id") == jsonData.id) {
						item.set('servercode', jsonData.servercode);
						item.set('address', jsonData.address);
						return false;
					}
				});
		Ext.getCmp('ide_service_regist_panel').hide();
	} else {
		Ext.Msg.show({
		     message: I18N.add_server_failed,
		     buttons: [
		    	 {text:'确定',itemId:'ok'},
		     ]
		});
	}
	Util.loadingMaskPanel.hide();
};
Util.processCer = function(cerInfoJson) {
	var processType = cerInfoJson.substring(1, cerInfoJson
					.indexOf(cmdFlag.CMDFlagSeperator));
	var jsonData = Ext.JSON.decode(cerInfoJson.substring(cerInfoJson
			.indexOf(cmdFlag.CMDFlagSeperator)
			+ 1));
	var store = Ext.data.StoreManager.lookup('cerStore');
	if (processType == 'D') {
		store.each(function(item, index, length) {
					if (item.get("id") == jsonData.id) {
						store.remove(item);
						return false;
					}
				});
	} else if (processType == 'L') {
		store.add(jsonData);
	} else {
		Ext.Msg.show({
		     message: I18N.operation_failed,
		     buttons: [
		    	 {text:'确定',itemId:'ok'},
		     ]
		});
	}
};
Util.uploadCer = function(cerId) {
	var cerEditPanel = Ext.create('HGMIDE.view.IDECerEditPanel');
	Ext.Viewport.add(cerEditPanel);
	cerEditPanel.show();
	if (cerId != 0) {
		var store = Ext.data.StoreManager.lookup('cerStore');
		store.each(function(item, index, length) {
					if (item.get("id") === cerId) {
						Ext.getCmp('pluginSelect').setValue(item.get('name'));
					}
				});
	}
	var submitBtn = Ext.getCmp('cerSubmitBtn');
	Ext.getCmp('cer_form_title').setTitle(I18N.upload_cer);
	submitBtn.setHandler(function() {
		Ext.Viewport.add(Util.loadingMaskPanel);
		$.ajax({
			url : "uploadCer?pluginName="
					+ Ext.getCmp('pluginSelect').getRecord().get('name'),
			success : function() {
				var options = {
					url : 'uploadCer',
					type : 'POST',
					success : function(data) {
						Util.loadingMaskPanel.hide();
						if (data === 'YES') {
							Ext.data.StoreManager.lookup('cerStore').add(Ext
									.getCmp('pluginSelect').getRecord());
							Ext.Msg.alert(I18N.promptTitle,
									I18N.cer_upload_success, function() {
										cerEditPanel.hide();
										Ext.getCmp('ide_setting_panel').hide();
									});
						} else if (data === 'FERROR') {
							Ext.Msg.show({
							     message: I18N.cer_format_error,
							     buttons: [
							    	 {text:'确定',itemId:'ok'},
							     ]
							});
						}
					}
				};
				$('#ide_cer_edit_panel').attr("enctype", "multipart/form-data");
				$('#ide_cer_edit_panel').submit(function() {
							$(this).ajaxSubmit(options);
							return false;
						});
				$('#ide_cer_edit_panel').submit();
			}
		});

	});
};
Util.deleteCer = function(cerId) {
	var cer;
	var store = Ext.data.StoreManager.lookup('cerStore');
	store.each(function(item, index, length) {
				if (item.get("id") === cerId) {
					cer = item;
				}
			});
	function callback(buttonId, value, opt) {
		if (buttonId == 'ok') {
			var cmdStr = cmdFlag.CMD4Cer + cmdFlag.CMDFlagSeperator + '-D'
					+ cmdFlag.CMDFlagSeperator + '{"id":' + cer.get('id')
					+ ',"name":"' + cer.get('name') + '","nameCN":"'
					+ cer.get('nameCN') + '","dept":"' + cer.get('dept')
					+ '","version":"' + cer.get('version') + '","frame":"'
					+ cer.get('frame') 
					+ '","isonline":"' + cer.get('isonline') 
					+ '","pluginType":"' + cer.get('pluginType') 
					+ '","url":"' + cer.get('url') 
					+ '","root":"' + cer.get('root') + '"}';
			send(cmdStr);
		}
	};
	Ext.Msg.show({
	     message: I18N.deletePluginAsking + '['+ cer.get('nameCN') + ']' + I18N.cer_confirm_info,
	     buttons: [
	    	 {text:'确定',itemId:'ok'},
	    	 {text:'取消',itemId:'cancel'}
	     ],
	     fn:callback
	});
};
Util.sendOperateServiceCmd = function(operateChar, serviceModel) {
	var cmdStr = cmdFlag.CMD4Service + cmdFlag.CMDFlagSeperator + '-'
			+ operateChar + cmdFlag.CMDFlagSeperator + '{"id":'
			+ serviceModel.get('id') + ',"servercode":"'
			+ serviceModel.get('servercode') + '","address":"'
			+ serviceModel.get('address') + '"}';
	send(cmdStr);
};

Util.editService = function(serviceId) {
	var serviceEditPanel = Ext.create('HGMIDE.view.IDEServiceRegistPanel');
	Ext.Viewport.add(serviceEditPanel);
	serviceEditPanel.show();
	var submitBtn = Ext.getCmp('serviceSubmitBtn');
	if (serviceId == 0) {
		Ext.getCmp('service_form_title').setTitle(I18N.regist_service);
		submitBtn.setHandler(function() {
					var values = serviceEditPanel.getValues();
					var serviceModel = Ext.create('HGMIDE.model.ServiceModel',
							{
								id : 0,
								servercode : values.servercode.trim(),
								address : values.address.trim()
							});
					Util.validateInfoService(serviceModel);
					serviceModel.data.servercode = I18N.serverCodeTitle + values.servercode.trim();
					if (Util.validateResult.isOk) {
						Ext.Viewport.add(Util.loadingMaskPanel);
						Util.loadingMaskPanel.show();
						Util.sendOperateServiceCmd('A', serviceModel);
					} else {
						Ext.Msg.show({
						     message: Util.validateResult.messages,
						     buttons: [
						    	 {text:'确定',itemId:'ok'},
						     ]
						});
					}
				});
	} else {
		Ext.getCmp('service_form_title').setTitle(I18N.service_edit);
		Ext.getCmp('serverFormCode').setDisabled(true);
		var obj = {};
		var store = Ext.data.StoreManager.lookup('serviceStore');
		store.each(function(item, index, length) {
					if (item.get("id") == serviceId) {
						obj['id'] = item.data.id;
						obj['servercode'] = item.data.servercode;
						obj['address'] = item.data.address;
						serviceEditPanel.setRecord(item);
						return false;
					}
				});
		submitBtn.setHandler(function() {
					var values = serviceEditPanel.getValues();
					var serviceModel = Ext.create('HGMIDE.model.ServiceModel',
							{
								id : values.id.trim(),
								servercode : values.servercode.trim(),
								address : values.address.trim()
							});
					Util.validateInfoService(serviceModel);
					if (Util.validateResult.isOk) {
						Ext.Viewport.add(Util.loadingMaskPanel);
						Util.loadingMaskPanel.show();
						Util.sendOperateServiceCmd('E', serviceModel);
					} else {
						serviceModel.setData(obj);
						Ext.Msg.show({
						     message: Util.validateResult.messages,
						     buttons: [
						    	 {text:'确定',itemId:'ok'},
						     ]
						});
					}
				});
	}
};
Util.deleteService = function(serviceId) {
	var service;
	var store = Ext.data.StoreManager.lookup('serviceStore');
	store.each(function(item, index, length) {
				if (item.get("id") == serviceId) {
					service = item;
					return false;
				}
			});
	function callback(buttonId, value, opt) {
		if (buttonId == 'ok') {
			Ext.Viewport.add(Util.loadingMaskPanel);
			Util.loadingMaskPanel.show();
			Util.sendOperateServiceCmd('D', service);
		}
	};
	Ext.Msg.show({
	     message: I18N.deletePluginAsking + ' '+ service.get('servercode') + '?',
	     buttons: [
	    	 {text:'确定',itemId:'ok'},
	    	 {text:'取消',itemId:'cancel'}
	     ],
	     fn:callback
	});
};
Util.showServiceDetails = function(serviceId) {
	var serviceDetailsPanel = Ext
			.create('HGMIDE.view.IDEServiceInfoDetailsPanel');
	Ext.Viewport.add(serviceDetailsPanel);
	serviceDetailsPanel.showBy(Ext.getCmp('ide_service_list'), 'cr-cl');
	var store = Ext.data.StoreManager.lookup('serviceStore');
	var serviceModel;
	store.each(function(item, index, length) {
				if (item.get("id") == serviceId) {
					serviceModel = item;
					return false;
				}
			});
	Ext.getCmp('s_details_servercode').setHtml(serviceModel.get('servercode'));
	Ext.getCmp('s_details_address').setHtml(serviceModel.get('address'));
};
Util.hideServiceDetails = function() {
	Ext.getCmp('ide_service_info_details_panel').hide();
};
Util.checkAppPublishStatus = function(jsonData) {
	setTimeout(function() {
				Ext.Ajax.request({
							url : 'http://' + window.location.host
									+ '/HGMIDE/plugin/' + jsonData.name + "/",
							method : 'GET',
							success : function(response, opts) {
								LOGD('success responseStatus' + response.status);
								var store = Ext.data.StoreManager
										.lookup('pluginListStore');
								store.add(jsonData);
								Util.setStatus();
								Util.loadingMaskPanel.hide();
								Ext.getCmp('waitingPanel')
										.setHtml(I18N.waiting);
								Util.openPlugin(jsonData.id);
							},
							failure : function(response, opts) {
								Util.checkAppPublishStatus(jsonData);
							}
						});
			}, 1000);
};
Util.processPlugin = function(pluginInfoJson) {
	var processType = pluginInfoJson.substring(1, pluginInfoJson
					.indexOf(cmdFlag.CMDFlagSeperator));
	var jsonData = Ext.JSON.decode(pluginInfoJson.substring(pluginInfoJson
			.indexOf(cmdFlag.CMDFlagSeperator)
			+ 1));
	var store = Ext.data.StoreManager.lookup('pluginListStore');
	if (processType == 'A') {
		Ext.getCmp('addPluginPanel').hide();
		Ext.getCmp('waitingPanel').setHtml(I18N.publishing);
		Util.checkAppPublishStatus(jsonData);
	} else if (processType == 'D') {
		EmulatorManager.removeEmulatorObj('emulator' + jsonData.id);
		EmulatorManager.currentEmulator = null;
		store.each(function(item, index, length) {
					if (item.get("id") == jsonData.id) {
						store.remove(item);
						return false;
					}
				});
		Util.setStatus();
		Util.loadingMaskPanel.hide();
	} else if (processType == 'L') {
		store.add(jsonData);
		if (store.getCount() > 0) {
			var plugin = store.getAt(0);
			Util.openPlugin(plugin.get('id'));
		}
		Util.loadingMaskPanel.hide();
	} else if (processType == 'E') {
		store.each(function(item, index, length) {
					if (item.get("id") == jsonData.id) {
						item.set('name', jsonData.name);
						item.set('nameCN', jsonData.nameCN);
						item.set('version', jsonData.version);
						item.set('dept', jsonData.dept);
						item.set('frame', jsonData.frame);
						item.set('isonline', jsonData.isonline);
						item.set('pluginType', jsonData.pluginType);
						item.set('url', jsonData.url);
						item.set('root', jsonData.root);
						return false;
					}
				});
		Ext.getCmp('addPluginPanel').hide();
		Util.setStatus();
		Util.loadingMaskPanel.hide();
	} else {
		Ext.Msg.show({
		     message: I18N.add_app_failed,
		     buttons: [
		    	 {text:'确定',itemId:'ok'},
		     ]
		});
		Util.loadingMaskPanel.hide();
	}

};
Util.sendOperatePluginCmd = function(operateChar, pluginModel) {
	var cmdStr = cmdFlag.CMD4App + cmdFlag.CMDFlagSeperator + '-' + operateChar
			+ cmdFlag.CMDFlagSeperator + '{"id":' + pluginModel.get('id')
			+ ',"name":"' + pluginModel.get('name') + '","nameCN":"'
			+ pluginModel.get('nameCN') + '","dept":"'
			+ pluginModel.get('dept') + '","version":"'
			+ pluginModel.get('version') + '","frame":"'
			+ pluginModel.get('frame') 
			+ '","isonline":"' + pluginModel.get('isonline')
			+ '","pluginType":"' + pluginModel.get('pluginType')
			+ '","url":"' + pluginModel.get('url')
			+ '","root":"' + pluginModel.get('root')
			+ '"}';
	send(cmdStr);
};
Util.editPlugin = function(pluginId) {
	var pluginEditPanel = Ext.create('HGMIDE.view.IDEPluginEditPanel');
	Ext.Viewport.add(pluginEditPanel);
	pluginEditPanel.show();
	var submitBtn = Ext.getCmp('pluginSubmitBtn');
	if (pluginId == 0) {
		Ext.getCmp('devFrame').setDisabled(false);
		Ext.getCmp('addPluginFieldSet').setTitle(I18N.plugin_add0);
		Ext.getCmp('isonlinebtn').setPressedButtons('out');
		Ext.getCmp('isonlinebtn').addListener('toggle',function(container, button,pressed){
			if (pressed) {
				var text= button.getText();
				if(text=="离线插件"){
					$("#url").hide();
					Ext.getCmp('url').setValue("");
					$("input[name='isonline']").val("0");
					$("#addPluginPanel").height("435px");
				}else{
					$("#url").show();
					Ext.getCmp('url').setValue("");
					$("input[name='isonline']").val("1");
					$("#addPluginPanel").height("480px");
				}

			}
		});
		submitBtn.setHandler(function() {
					var values = pluginEditPanel.getValues();
					var pluginModel = Ext.create('HGMIDE.model.PluginModel', {
								id : 0,
								name : values.name.trim(),
								nameCN : values.nameCN.trim(),
								dept : values.dept.trim(),
								version : values.version.trim(),
								frame : values.frame.trim(),
								url : values.url.trim(),
								isonline : values.isonline.trim(),
								pluginType : values.pluginType.trim(),
								root : '.'
							});
					Util.validateInfoPlugin(pluginModel);
					pluginModel.data.name = I18N.pluginNameTitle + values.name.trim();
					if (Util.validateResult.isOk) {
						Ext.Viewport.add(Util.loadingMaskPanel);
						Util.loadingMaskPanel.show();
						Util.sendOperatePluginCmd('A', pluginModel);
					} else {
						Ext.Msg.show({
						     message: Util.validateResult.messages,
						     buttons: [
						    	 {text:'确定',itemId:'ok'},
						     ]
						});
					}
				});
	} else {
		Ext.getCmp('addPluginFieldSet').setTitle(I18N.plugin_edit);
		Ext.getCmp('devFrame').setDisabled(true);
		Ext.getCmp('pluginFormName').setDisabled(true);
		//设置clearIcon编辑时为true
		Ext.getCmp('nameCN').setClearIcon(true);
		Ext.getCmp('dept').setClearIcon(true);
		Ext.getCmp('version').setClearIcon(true);
		Ext.getCmp('url').setClearIcon(true);
		var obj = {};
		var store = Ext.data.StoreManager.lookup('pluginListStore');
		store.each(function(item, index, length) {
					if (item.get("id") == pluginId) {
						obj['id'] = item.data.id;
						obj['name'] = item.data.name;
						obj['nameCN'] = item.data.nameCN;
						obj['dept'] = item.data.dept;
						obj['version'] = item.data.version;
						obj['frame'] = item.data.frame;
						obj['isonline'] = item.data.isonline;
						obj['pluginType'] = item.data.pluginType;
						obj['url'] = item.data.url;
						obj['root'] = item.data.root;
						if(item.data.isonline==undefined){
							item.data.isonline=item.raw.isonline;
						}
						if(item.data.pluginType==undefined){
							item.data.pluginType=item.raw.pluginType;
						}
						if(item.data.url==undefined){
							item.data.url = item.raw.url;
						}
						if(item.data.isonline=="0"){
							//离线插件
							Ext.getCmp('isonlinebtn').addListener('toggle',function(container, button,pressed){
								Ext.getCmp('isonlinebtn').setPressedButtons('out');
								Ext.Msg.show({
								     message: I18N.noSwitch,
								     buttons: [
								    	 {text:'确定',itemId:'ok'},
								     ]
								});
							});
							Ext.getCmp('url').setValue("");
							$("#url").hide();
							$("#out").addClass("x-button-pressed");
							$("#on").removeClass("x-button-pressed");
							Ext.getCmp('isonline').setValue("0");
							$("#addPluginPanel").height("435px");
						}else{
							//在线插件
							Ext.getCmp('isonlinebtn').addListener('toggle',function(container, button,pressed){
								Ext.getCmp('isonlinebtn').setPressedButtons('on');
								Ext.Msg.show({
								     message: I18N.noSwitch,
								     buttons: [
								    	 {text:'确定',itemId:'ok'},
								     ]
								});
							});
							Ext.getCmp('url').setHidden(false);
							$("#on").addClass("x-button-pressed");
							$("#out").removeClass("x-button-pressed");
							Ext.getCmp('isonline').setValue("1");
							$("#addPluginPanel").height("480px");
						}
						pluginEditPanel.setRecord(item);
						return false;
					}
				});
		
		submitBtn.setHandler(function() {
					var values = pluginEditPanel.getValues();
					var pluginModel = Ext.create('HGMIDE.model.PluginModel', {
								id : values.id,
								name : values.name.trim(),
								nameCN : values.nameCN.trim(),
								dept : values.dept.trim(),
								version : values.version.trim(),
								frame : values.frame.trim(),
								isonline : values.isonline.trim(),
								pluginType : values.pluginType.trim(),
								url : values.url.trim(),
								root : '.'
							});
					Util.validateInfoPlugin(pluginModel);
					if (Util.validateResult.isOk) {
						Ext.Viewport.add(Util.loadingMaskPanel);
						Util.loadingMaskPanel.show();
						Util.sendOperatePluginCmd('E', pluginModel);
					} else {
						pluginModel.setData(obj);
						Ext.Msg.show({
						     message: Util.validateResult.messages,
						     buttons: [
						    	 {text:'确定',itemId:'ok'},
						     ]
						});
					}
				});
	}
};
Util.validateInfoUser = function(model) {
	if(Util.isEmpty(model.data.loginname)){
		Util.validateResult.isOk = false;
		Util.validateResult.messages = I18N.error_message.userError.loginname_null;
		return;
	}
	if(Util.isEmpty(model.data.guid)){
		Util.validateResult.isOk = false;
		Util.validateResult.messages = I18N.error_message.userError.guid_null;
		return;
	}
	if(Util.isEmpty(model.data.usercode)){
		Util.validateResult.isOk = false;
		Util.validateResult.messages = I18N.error_message.userError.usercode_null;
		return;
	}
	if(Util.isEmpty(model.data.username)){
		Util.validateResult.isOk = false;
		Util.validateResult.messages = I18N.error_message.userError.username_null;
		return;
	}
	if(Util.isEmpty(model.data.dept)){
		Util.validateResult.isOk = false;
		Util.validateResult.messages = I18N.error_message.userError.dept_null;
		return;
	}
	if(Util.isEmpty(model.data.email)){
		Util.validateResult.isOk = false;
		Util.validateResult.messages = I18N.error_message.userError.email_null;
		return;
	}
	var matcht = /.\\./;
	if(!matcht.test(model.data.loginname)){
		Util.validateResult.isOk = false;
    	Util.validateResult.messages = I18N.error_message.userError.loginname_format;
    	return;
	}
	matcht = /\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/;
	if(!matcht.test(model.data.email)){
    	Util.validateResult.isOk = false;
    	Util.validateResult.messages = I18N.error_message.userError.email_format;
    	return;
	}
	
	Util.validateResult.isOk = true;
};
Util.validateInfoPlugin = function(model) {
	//插件名称
	if(Util.isEmpty(model.data.nameCN)){
		Util.validateResult.isOk = false;
		Util.validateResult.messages = I18N.error_message.pluginError.cn_name_null;
		return;
	}
	//插件标识
	if(Util.isEmpty(model.data.name)){
		Util.validateResult.isOk = false;
		Util.validateResult.messages = I18N.error_message.pluginError.en_name_null;
		return;
	}
	//插件标识为字母数字和-
	var matcht =  /^[A-Za-z0-9-]+$/ig;
	if(!matcht.test(model.data.name)){
		Util.validateResult.isOk = false;
		Util.validateResult.messages = I18N.error_message.pluginError.en_name_formart;
		return;
	}
	//开发框架
	if(Util.isEmpty(model.data.frame)){
		Util.validateResult.isOk = false;
		Util.validateResult.messages = I18N.error_message.pluginError.frame_null;
		return;
	}
	//单位名称
	if(Util.isEmpty(model.data.dept)){
		Util.validateResult.isOk = false;
		Util.validateResult.messages = I18N.error_message.pluginError.dept_null;
		return;
	}
	//版本
	if(Util.isEmpty(model.data.version)){
		Util.validateResult.isOk = false;
		Util.validateResult.messages = I18N.error_message.pluginError.version_null;
		return;
	}
	if(!Util.isEmpty(model.data.isonline)){
		//判断是离线插件还是在线插件
		if(model.data.isonline=='1'){
			//在线插件
			if(!Util.isEmpty(model.data.url)){
				var matcht = /[a-zA-Z]{4,5}:\/\/.*?:\d{2,}\/[\s\S]+/;
				if(!matcht.test(model.data.url)){
			    	Util.validateResult.isOk = false;
			    	Util.validateResult.messages = I18N.error_message.pluginError.url_formart;
			    	return;
				}
				var ip_ip = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
			    var ip_port = /^([0-9]|[1-9]\d{1,3}|[1-5]\d{4}|6[0-5]{2}[0-3][0-5])$/;
			    if (!ip_ip.test(model.data.url.split("//")[1].split("/")[0].split(":")[0])) {
			    	Util.validateResult.isOk = false;
			    	Util.validateResult.messages = I18N.error_message.pluginError.url_formart;
			    	return;
		        }
			    if (!ip_port.test(model.data.url.split("//")[1].split("/")[0].split(":")[1])) {
			    	Util.validateResult.isOk = false;
			    	Util.validateResult.messages = I18N.error_message.pluginError.url_formart;
			    	return;
		        }
			}else{
				//在线插件url为空
				Util.validateResult.isOk = false;
		    	Util.validateResult.messages = I18N.error_message.pluginError.url_null;
		    	return;
			}
		}
	}
	Util.validateResult.isOk = true;
};
Util.validateInfoService = function(model) {
	//服务标识
	if(Util.isEmpty(model.data.servercode)){
		Util.validateResult.isOk = false;
		Util.validateResult.messages = I18N.error_message.serviceError.servicecode_null;
		return;
	}
	//ip
	if(Util.isEmpty(model.data.address)){
		Util.validateResult.isOk = false;
		Util.validateResult.messages = I18N.error_message.serviceError.address_null;
		return;
	}
	//插件标识为字母数字和-
	var matcht =  /^[A-Za-z0-9-]+$/ig;
	if(!matcht.test(model.data.servercode)){
		Util.validateResult.isOk = false;
		Util.validateResult.messages = I18N.error_message.serviceError.servicecode_format;
		return;
	}
	var matcht =/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\:([0-9]|[1-9]\d{1,3}|[1-5]\d{4}|6[0-5]{2}[0-3][0-5])$/;
	if(!matcht.test(model.data.address)){
    	Util.validateResult.isOk = false;
    	Util.validateResult.messages = I18N.error_message.serviceError.address_format;
    	return;
	}
	Util.validateResult.isOk = true;
};
Util.deletePlugin = function(pluginId) {
	var plugin;
	var store = Ext.data.StoreManager.lookup('pluginListStore');
	store.each(function(item, index, length) {
				if (item.get("id") == pluginId) {
					plugin = item;
					return false;
				}
			});
	function callback(buttonId, value, opt) {
		if (buttonId == 'ok') {
			Ext.Viewport.add(Util.loadingMaskPanel);
			Util.loadingMaskPanel.show();
			Util.sendOperatePluginCmd('D', plugin);
			var emulatorContainer = Ext.getCmp('emulatorContainer' + pluginId);
			if (emulatorContainer != null) {
				emulatorContainer.hide();
				emulatorContainer.destroy();
			}
		}
	};
	Ext.Msg.show({
	     message: I18N.deletePluginAsking + ' ' + plugin.get('nameCN') + '?',
	     buttons: [
	    	 {text:'确定',itemId:'ok'},
	    	 {text:'取消',itemId:'cancel'}
	     ],
	     fn:callback
	});
};
Util.openPlugin = function(pluginId) {
	var store = Ext.data.StoreManager.lookup('pluginListStore');
	store.each(function(item, index, length) {
				if (item.get("id") == pluginId) {
					Util.pluginOpenable = true;
					return false;
				} else {
					Util.pluginOpenable = false;
				}
			});
	if (!Util.pluginOpenable) {
		return;
	}
	var isExists = false;
	for (var i = 0; i < EmulatorManager.emulators.length; i++) {
		if (EmulatorManager.emulators[i].id == 'emulator' + pluginId) {
			isExists = true;
			break;
		} else {
			continue;
		}
	}
	if (!isExists) {
		var emulatorCmp = Ext.create('HGMIDE.view.IDEEmulator', {
					id : 'emulatorContainer' + pluginId
				});
		var emulatorButtonGroup = Ext.create('HGMIDE.view.EmulatorButtonGroup',
				{
					id : 'btnGroup' + pluginId
				});
		var fullScreenButton = Ext.create('HGMIDE.view.FullScreenButton', {
					id : 'fullScreenBtn' + pluginId
				});

		var pluginSideButon = Ext.create('HGMIDE.view.PluginSideButton', {
					id : 'pluginSideBtn' + pluginId
				});
		var pluginName;

		store.each(function(item, index, length) {
					if (item.get("id") == pluginId) {
						pluginName = item.get('name');
						return false;
					}
				});
		var emulator = Ext.create('HGMIDE.view.IDEEmulatorScreen', {
			id : 'emulator' + pluginId,
			width : '100%',
			height : '100%',
			items : [{
				xtype : 'panel',
				cls : 'emulator_screen_panel',
				html : "<iframe id='emulatorIframe"
						+ pluginId
						+ "' name='emulatorIframe' frameborder='0' width='100%' height='100%' src='/HGMIDE/plugin/"
						+ pluginName + "/'></iframe>"
			}]
		});
		var screenPanel = emulator.query('panel')[0];
		screenPanel
				.setStyle('border-width:1px;border-color:#1e90ff;border-style:solid;width:'
						+ Emulator.predefineWidth
						+ 'px;height:'
						+ Emulator.predefineHeight + 'px;');
		emulatorButtonGroup.add(fullScreenButton);
		emulatorButtonGroup.add(pluginSideButon);
		emulatorCmp.add(emulatorButtonGroup);
		emulatorCmp.add(emulator);
		var emulatorObj = new Emulator();
		emulatorObj.id = 'emulator' + pluginId;
		emulatorObj.width = Emulator.predefineWidth;
		emulatorObj.height = Emulator.predefineHeight;
		emulatorObj.isOpened = true;
		Ext.Array.include(EmulatorManager.emulators, emulatorObj);
		Ext.getCmp('ide_emulator_work_space').add(emulatorCmp);
		Ext.Array.each(EmulatorManager.emulators, function(value, index,
						emulators) {
					if (value.id != 'emulator' + pluginId) {
						Ext
								.getCmp('emulatorContainer'
										+ value.id.substring(value.id
												.indexOf('r')
												+ 1)).setHidden(true);
					}
				});
	} else {
		var emulator = Ext.getCmp('emulatorContainer' + pluginId);
		if (emulator.getHidden()) {
			emulator.setHidden(false);
		}
		Ext.Array.each(EmulatorManager.emulators, function(value, index,
						emulators) {
					if (value.id != 'emulator' + pluginId) {
						Ext
								.getCmp('emulatorContainer'
										+ value.id.substring(value.id
												.indexOf('r')
												+ 1)).setHidden(true);
					} else {
						value.isOpened = true;
					}
				});
	}
	EmulatorManager.currentEmulator = Ext.getCmp('emulator' + pluginId);
	var pluginStatusImg = document.getElementById('pluginStatus' + pluginId);
	pluginStatusImg.style.display = 'inline';

	var fullScreenButtonDom = Ext.getDom('fullScreenBtn' + pluginId);
	fullScreenButtonDom.onmouseover = function() {
		Util.btnTipText.setWidth('58PX');
		if (EmulatorManager.getEmulatorObj('emulator' + pluginId).isFullScreen) {
			Util.btnTipText.setHtml(I18N.closeFullscreen);
		} else {
			Util.btnTipText.setHtml(I18N.openFullscreen);
		};
		Util.btnTipText.showBy(Ext.getCmp('fullScreenBtn' + pluginId));
	};
	fullScreenButtonDom.onmouseout = function() {
		Util.btnTipText.hide();
	};
	var pluginSideButonDom = Ext.getDom('pluginSideBtn' + pluginId);
	var pluginManagerSpace = Ext.getCmp('ide_plugin_manage_space');
	pluginSideButonDom.onmouseover = function() {
		Util.btnTipText.setWidth('100PX');
		if (pluginManagerSpace.getHidden()) {
			Util.btnTipText.setHtml(I18N.showPluginList);
		} else {
			Util.btnTipText.setHtml(I18N.hidePluginList);
		}

		Util.btnTipText.showBy(Ext.getCmp('pluginSideBtn' + pluginId));
	};
	pluginSideButonDom.onmouseout = function() {
		Util.btnTipText.hide();
	};
};
Util.closePlugin = function(pluginId) {
	var emulatorContainer = Ext.getCmp('emulatorContainer' + pluginId);
	emulatorContainer.hide();
	var pluginStatusImg = document.getElementById('pluginStatus' + pluginId);
	pluginStatusImg.style.display = 'none';
	EmulatorManager.getEmulatorObj('emulator' + pluginId).isOpened = false;
	EmulatorManager.currentEmulator = null;
};
Util.processUser = function(userInfoJson) {
	var processType = userInfoJson.substring(1, userInfoJson
					.indexOf(cmdFlag.CMDFlagSeperator));
	var jsonData = Ext.JSON.decode(userInfoJson.substring(userInfoJson
			.indexOf(cmdFlag.CMDFlagSeperator)
			+ 1));
	var store = Ext.data.StoreManager.lookup('userStore');
	if (processType == 'A') {
		store.add(jsonData);
		Ext.getCmp('ide_user_info_edit_panel').hide();
	} else if (processType == 'D') {
		store.each(function(item, index, length) {
					if (item.get("id") == jsonData.id) {
						store.remove(item);
						return false;
					}
				});
	} else if (processType == 'L') {
		store.add(jsonData);
	} else if (processType == 'E') {
		store.each(function(item, index, length) {
					if (item.get("id") == jsonData.id) {
						item.set('guid', jsonData.guid);
						item.set('usercode', jsonData.usercode);
						item.set('username', jsonData.username);
						item.set('dept', jsonData.dept);
						return false;
					}
				});
		Ext.getCmp('ide_user_info_edit_panel').hide();
	} else {
		Ext.Msg.show({
		     message: I18N.add_user_failed,
		     buttons: [
		    	 {text:'确定',itemId:'ok'},
		     ]
		});
	}
	Util.loadingMaskPanel.hide();
};

Util.sendOperateUserCmd = function(operateChar, userModel) {
	var cmdStr = cmdFlag.CMD4User + cmdFlag.CMDFlagSeperator + '-'
			+ operateChar + cmdFlag.CMDFlagSeperator + '{"id":'
			+ userModel.get('id') + ',"guid":"' + userModel.get('guid')
			+ '","usercode":"' + userModel.get('usercode') + '","username":"'
			+ userModel.get('username') + '","dept":"' + userModel.get('dept')
			+ '","email":"' + userModel.get('email')+ '","loginname":"' + userModel.get('loginname').replace(/\\/g, "\\\\")
			+ '"}';
	send(cmdStr);
};
Util.showUserDetails = function(userId) {
	var userInfoDetailsPanel = Ext
			.create('HGMIDE.view.IDEUserInfoDetailsPanel');
	Ext.Viewport.add(userInfoDetailsPanel);
	userInfoDetailsPanel.showBy(Ext.getCmp('ide_user_list'), 'cr-cl');
	// find usermodel by id
	var store = Ext.data.StoreManager.lookup('userStore');
	var userModel;
	store.each(function(item, index, length) {
				if (item.get("id") == userId) {
					userModel = item;
					return false;
				}
			});
	Ext.getCmp('u_details_loginname').setHtml(userModel.get('loginname'));
	Ext.getCmp('u_details_guid').setHtml(userModel.get('guid'));
	Ext.getCmp('u_details_usercode').setHtml(userModel.get('usercode'));
	Ext.getCmp('u_details_username').setHtml(userModel.get('username'));
	Ext.getCmp('u_details_dept').setHtml(userModel.get('dept'));
	Ext.getCmp('u_details_email').setHtml(userModel.get('email'));
};
Util.hideUserDetails = function() {
	Ext.getCmp('ide_user_info_details_panel').hide();
};
Util.editUser = function(userId) {
	var userEditPanel = Ext.create('HGMIDE.view.IDEUserInfoEditPanel');
	Ext.Viewport.add(userEditPanel);
	userEditPanel.show();
	var submitBtn = Ext.getCmp('userInfoSubmitBtn');
	if (userId == 0) {
		Ext.getCmp('user_info_form_title').setTitle(I18N.user_add);
		submitBtn.setHandler(function() {
					var values = userEditPanel.getValues();
					var userModel = Ext.create('HGMIDE.model.UserModel', {
								id : 0,
								guid : values.guid,
								usercode : values.usercode,
								username : values.username,
								dept : values.dept,
								email : values.email,
								loginname : values.loginname
							});

					Util.validateInfoUser(userModel);
					if (Util.validateResult.isOk) {
						Ext.Viewport.add(Util.loadingMaskPanel);
						Util.loadingMaskPanel.show();
						Util.sendOperateUserCmd('A', userModel);
					} else {
						Ext.Msg.show({
						     message: Util.validateResult.messages,
						     buttons: [
						    	 {text:'确定',itemId:'ok'},
						     ]
						});
					}

				});
	} else {
		Ext.getCmp('user_info_form_title').setTitle(I18N.user_edit);
		Ext.getCmp('loginname').setDisabled(true);
		var obj = {};
		var store = Ext.data.StoreManager.get('userStore');
		store.each(function(item, index, length) {
					if (item.get("id") == userId) {
						obj['id'] = item.data.id;
						obj['guid'] = item.data.guid;
						obj['usercode'] = item.data.usercode;
						obj['username'] = item.data.username;
						obj['dept'] = item.data.dept;
						obj['email'] = item.data.email;
						obj['loginname'] = item.data.loginname;
						userEditPanel.setRecord(item);
						return false;
					}
				});
		submitBtn.setHandler(function() {
					var values = userEditPanel.getValues();
					var userModel = Ext.create('HGMIDE.model.UserModel', {
								id : values.id,
								guid : values.guid,
								usercode : values.usercode,
								username : values.username,
								dept : values.dept,
								email : values.email,
								loginname : values.loginname
							});
					Util.validateInfoUser(userModel);
					if (Util.validateResult.isOk) {
						Ext.Viewport.add(Util.loadingMaskPanel);
						Util.loadingMaskPanel.show();
						Util.sendOperateUserCmd('E', userModel);
					} else {
						userModel.setData(obj);
						Ext.Msg.show({
						     message: Util.validateResult.messages,
						     buttons: [
						    	 {text:'确定',itemId:'ok'},
						     ]
						});
					}
				});
	}
};
Util.deleteUser = function(userId) {
	var user;
	var store = Ext.data.StoreManager.lookup('userStore');
	store.each(function(item, index, length) {
				if (item.get("id") == userId) {
					user = item;
					return false;
				}
			});
	function callback(buttonId, value, opt) {
		if (buttonId == 'ok') {
			Ext.Viewport.add(Util.loadingMaskPanel);
			Util.loadingMaskPanel.show();
			Util.sendOperateUserCmd('D', user);
		}
	};
	Ext.Msg.show({
	     message: I18N.deletePluginAsking + ' '+ user.get('username') + '?',
	     buttons: [
	    	 {text:'确定',itemId:'ok'},
	    	 {text:'取消',itemId:'cancel'}
	     ],
	     fn:callback
	});
};
/**
 * process the json data of device infomation
 * 
 * @param {Object}
 *            deviceJsonData
 */
Util.processDevice = function(deviceJsonData) {
	var processType = deviceJsonData.substring(deviceJsonData.indexOf('-') + 1,
			deviceJsonData.indexOf('-') + 2);
	var jsonData = deviceJsonData.substring(deviceJsonData
			.indexOf(cmdFlag.CMDFlagSeperator)
			+ 1);
	var store = Ext.data.StoreManager.lookup('devicestore');
	if (processType == 'A') {
		store.add(Ext.JSON.decode(jsonData));
	} else if (processType == 'D') {
		var deviceId = Ext.JSON.decode(jsonData).deviceId;
		store.each(function(item, index, length) {
					if (item.get("deviceId") == deviceId) {
						store.remove(item);
						return false;
					}
				});
	} else if (processType == 'L') {
		store.add(Ext.JSON.decode(jsonData));
	}
	Ext.getCmp('runBtn').setBadgeText(store.getCount());
	var deviceList = Ext.getCmp('devicesConnected');
	deviceList.setStore(null);
	deviceList.setStore(store);
};
Util.getLogJson = function(message) {
	return Ext.JSON.decode(message.substring(message
			.indexOf(cmdFlag.CMDFlagSeperator)
			+ 1));
};
Util.processLog = function(logjson) {
	var title = logjson.title;
	var content = logjson.content;
	var type = logjson.type;
	var flag = content.substring(1, 2);
	var logInfoType;
	switch (flag) {
		case 'D' :
			logInfoType = Logger.logInfoType.debug;
			break;
		case 'I' :
			logInfoType = Logger.logInfoType.common;
			break;
		case 'W' :
			logInfoType = Logger.logInfoType.warning;
			break;
		case 'E' :
			logInfoType = Logger.logInfoType.error;
			break;
	}
	Logger.doLog(logInfoType, title, content, type);
};
/**
 * Analytical IdCode from message
 * 
 * @param {Object}
 *            message The message from server
 */
Util.getIdCode = function(message) {
	return message.substring(message.indexOf(cmdFlag.CMDFlagSeperator) + 1);
};
/**
 * process IDCode
 * 
 * @param {Object}
 *            idCode
 */
Util.processIdCode = function(idCode) {
	Ext.getCmp('connectCode').setHtml(idCode);
	Ext.getCmp('qrcodeImage').setSrc('http://' + window.location.host
			+ '/'+SysCfg.projectName+'/QRCodeGenerator?' + Math.floor(Math.random() * 1000));
};
Util.changeEmulatorSrc = function(src) {
	var id = EmulatorManager.currentEmulator.getId();
	Ext.getDom('emulatorIframe' + id.substring(id.length - 1)).src = src;
};
Util.getInfoJson = function(message) {
	return message.substring(message.indexOf(cmdFlag.CMDFlagSeperator) + 1);
};
function mousePos(e) {
	var x, y;
	var e = e || window.event;
	return {
		x : e.clientX,
		y : e.clientY
	};
};
Util.hideDeviceOverlay = function(event) {
	var left = Util.overlay.getLeft();
	var top = Util.overlay.getTop();
	var position = mousePos(event);
	var maxLeft = left + parseInt(Util.overlay.getWidth());
	var maxTop = top + parseInt(Util.overlay.getHeight());
	if (position.x < left || position.x > maxLeft || position.y < top
			|| position.y > maxTop) {
		Util.inDeviceListPanel = false;
		if (Util.hideDeviceListTimeOver) {
			document.onmousemove = null;
			Util.overlay.hide();
			Util.hideDeviceListTimeOver = false;
		}
	} else {
		Util.inDeviceListPanel = true;
	}
};
Util.hideLoggerChoose = function(event) {
	var left = Util.loggerChoosePanel.getLeft();
	var top = Util.loggerChoosePanel.getTop();
	var position = mousePos(event);
	var maxLeft = left + parseInt(Util.loggerChoosePanel.getWidth());
	var maxTop = top + parseInt(Util.loggerChoosePanel.getHeight());
	if (position.x < left || position.x > maxLeft || position.y < top
			|| position.y > maxTop) {
		Util.inLoggerChoosePanel = false;
		if (Util.hideLoggerChooseTimeOver) {
			document.onmousemove = null;
			Util.loggerChoosePanel.hide();
			Util.hideLoggerChooseTimeOver = false;
		}
	} else {
		Util.inLoggerChoosePanel = true;
	}
};
Util.showAlterPwdPanel = function() {
	var alterPwdPanel = Ext.create('HGMIDE.view.AlterPwd');
	Ext.Viewport.add(alterPwdPanel);
	alterPwdPanel.show();
};
Util.alterPwd = function () {
	var values = Ext.getCmp('alter_pwd_panel').getValues();
	var isPass = true;
	var msg = '';
	if(values.oldPwd.trim() == null ||
		values.oldPwd.trim() == ''){
		msg += I18N.error_message.developerError.oldPwd_null + '<br/>';
		isPass = false;
	}else if (values.password.trim() == null ||
		values.password.trim() == '') {
		msg += I18N.error_message.developerError.newPwd_null + '<br/>';
		isPass = false;
	} else if (values.confirmPwd.trim() == null ||
		values.confirmPwd.trim() == '') {
		msg += I18N.error_message.developerError.newRePwd_null +
			'<br/>';
		isPass = false;
	} else if (values.password.trim() != null &&
		values.password.trim() != values.confirmPwd.trim()) {
		msg += I18N.error_message.developerError.pwd_different +
			'<br/>';
		isPass = false;
	}
	if (!isPass) {
		Ext.Msg.show({
		     message: msg,
		     buttons: [
		    	 {text:'确定',itemId:'ok'},
		     ]
		});
		return;
	}
	if(values.oldPwd.trim() != Util.currentDeveloper.get('password')){
		Ext.Msg.show({
		     message: I18N.error_message.developerError.pwd_wrong,
		     buttons: [
		    	 {text:'确定',itemId:'ok'},
		     ]
		});
		return;
	}
	Ext.Ajax.request({
		url: 'login',
		method: 'POST',
		params: {
			action: 'pwd',
			password: values.password.trim()
		},
		success: function (response) {
			var text = response.responseText;
			if (text == 'OK') {
				Util.currentDeveloper.set('password',values.password.trim());
				Ext.Msg.show({
				     message: I18N.alterSucces,
				     buttons: [
				    	 {text:'确定',itemId:'ok'},
				     ],function(buttonId,value,opt){
							Ext.getCmp('alter_pwd_panel').hide();
				     }
				});
			} else if (text == 'NO') {
				Ext.Msg.show({
				     message: I18N.alterFaile,
				     buttons: [
				    	 {text:'确定',itemId:'ok'},
				     ]
				});
			}
		}
	});
};

Util.setStatus = function() {
	var size = EmulatorManager.emulators.length;
	var emulator;
	var emulatorId;
	for (var i = 0; i < size; i++) {
		emulator = EmulatorManager.emulators[i];
		if (emulator != null && emulator.isOpened) {
			emulatorId = emulator.id;
			var idNum = emulatorId.substring(emulatorId.indexOf('r') + 1);
			var img = document.getElementById('pluginStatus' + idNum);
			if (img != null) {
				img.style.display = 'inline';
			}
		}
	}
};

Util.overlay = null;
Util.sizeListPanel = null;
Util.errorInfoPanel = null;
Util.loggerChoosePanel = null;
Util.sizelistvisiable = false;
Util.btnTipText = null;
Util.settingPanel = null;
Util.loadingMaskPanel = null;
Util.pluginOpenable = true;
Util.hideDeviceListTimeOver = false;
Util.hideLoggerChooseTimeOver = false;
Util.inDeviceListPanel = false;
Util.inLoggerChoosePanel = false;
Util.runMode = 'debug';
Util.logMode = 'AllDevices';
Util.currentDeveloper = null;
Util.logCount = 1;
Util.consoleCount = 1;
Util.logMaxCount = 200;
Util.validateResult = {
	isOk : false,
	messages : null
};
Util.created = false;
Util.isSettingPanelShowing = false;
Util.pluginpath;